<%--
  Created by IntelliJ IDEA.
  User: liliting
  Date: 2020/11/16
  Time: 下午4:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/bootstrap.min.css">
    <script src="/static/js/jquery-2.2.4.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#btn").click(function(event){
                //得到表达的值
               var data =  $("#myForm").serialize();
                //var  username = $("#username").val();
                   console.log(data);// 400  服务端的数据的格式跟前端不匹配  一般日期
                $.ajax({
                    url:"/registerAction1",
                    data:data,
                    dataType:"json",
                    type:"post",
                    success:function(r){
                        console.log(r);
                        if(r.code==0){
                            alert('注册成功！！');
                        }
                    }
                });
            });
            event.preventDefault();//阻止默认行为
        });
    </script>
</head>
<body>

    <form id="myForm">
        <div>
            <label>
                用户名
            </label>
            <input id="username" type="text" name="username" class="form-control">
        </div>
        <div>
            <label>
                密码
            </label>
            <input type="text" id="pwd" name="password" class="form-control">
        </div>
        <div>
            <label>
                生日
            </label>
            <input type="text" id="birthdate" name="birthdate" class="form-control">
        </div>
        <div>
            <label>
                年龄
            </label>
            <input type="text" id="age"  class="form-control">
        </div>
        <div>
            <label>
                爱好
            </label>
            <input type="checkbox" name="hobby" value="football">足球
            <input type="checkbox" name="hobby" value="basketball">足球
            <input type="checkbox" name="hobby" value="PingPong">乒乓球
        </div>
        <div>
            <input type="button" class="btn-success" id="btn" value="提交"/>
        </div>
    </form>

</body>
</html>
